package com.bjowernode.springboot.config;

import com.bjowernode.springboot.servlet.MyServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration //将此类定义为配置类（相当于xml文件）
public class MyServletConfig {

    /**
     * @bean 是一个方法级别上的注解，主要用在配置类里
     * 相当于一个
     * <beans>
     *     <bean id="" class=""></bean>
     * </beans>
     * */
    @Bean
    public ServletRegistrationBean myServletRegistrationBean(){

        ServletRegistrationBean bean=new ServletRegistrationBean(new MyServlet(),"/myservlet");
        return bean;
    }
}
